package com.qire.manhua.dal.service;

import com.qire.antsbinder.dal.DataService;
import com.qire.antsbinder.dal.annotation.StrategyAnnotation;
import com.qire.common.basic.ObjectUtil;
import com.qire.common.constant.Url;
import com.qire.common.dal.WarehouseFactory;
import com.qire.manhua.dal.IUserDataDAL;
import com.qire.manhua.model.viewModel.impl.UserCenterViewModel;
import com.qire.manhua.model.vo.UserDetailVO;

public class UserCenterService extends DataService {

    private IUserDataDAL userDataDAL = WarehouseFactory.create(this, IUserDataDAL.class);

    private UserCenterViewModel viewModel;

    public UserCenterService(UserCenterViewModel viewModel) {
        this.viewModel = viewModel;
    }

    public void refreshUserDetailData() {
        userDataDAL.refreshUserDetailData();
    }

    @StrategyAnnotation(event = Url.myIndex)
    public void refreshUserDetailDataCallback(UserDetailVO dataVO, boolean isCache) {
        viewModel.refreshLayoutFinish(300);

        if(ObjectUtil.isNull(dataVO)) {
            return;
        }
        dataVO.updateUserEntity();

        viewModel.refreshUI();
    }

}
